﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Example06.aspx.cs" Inherits="Chapter26.Example06" %>

<!DOCTYPE html>

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>代码清单 26-6 读取和创建 cookie</title>
    <meta name="author" content="Adam Freeman" />
    <meta name="description" content="A simple example" />
</head>
<body>
    <p id="cookiedata"></p>
    <button id="write">Add Cookie</button>
    <button id="update">Update Cokkie</button>
    <script>
        var cookieCount = 0;
        document.getElementById("write").onclick = createCookie;
        document.getElementById("update").onclick = updateCookie;

        function createCookie() {
            cookieCount++;
            document.cookie = "Cookie_" + cookieCount + "=Value_" + cookieCount;
            readCookies();
        }

        function updateCookie() {
            document.cookie = "Cookie_" + cookieCount + "=Updated_" + cookieCount;
            readCookies();
        }

        function readCookies() {
            document.getElementById("cookiedata").innerHTML = document.cookie;
        }
    </script>
</body>
</html>
